package webapi

import (
	"fmt"
	"net/http"
	controller "photoPlugIn/webApiController"
	microcloud "photoPlugIn/webApiFramework"
	"time"
)

func InitWebApi() {
	server := &http.Server{
		Addr:        ":8080",
		Handler:     microcloud.Router,
		ReadTimeout: 5 * time.Second,
	}
	RegiterRouter(microcloud.Router)
	err := server.ListenAndServe()
	if err != nil {
		fmt.Println("start server error")
	}
	fmt.Println("start server success")
}

func RegiterRouter(handler *microcloud.RouterHandler) {
	new(controller.UserConterller).Router(handler)
}

// 代码来源：https://blog.csdn.net/afront/article/details/89410200
// 参考 https://www.jianshu.com/p/fe502c586034
